<template>
  <div class="component-header">
    <div class="header-content supervise_viewer">
      <div>

      </div>
    </div>

    <div class="header-content">
      <div class="home-header" v-if="showLogo">
        <img :src="image.logo" width="112" height="28"/>
        <div>
          <el-menu :default-active="headerIndex" mode="horizontal" :ellipsis="false">
            <el-menu-item index="0">我的课堂</el-menu-item>
          </el-menu>
        </div>
      </div>

      <div style="display: flex; justify-content: space-between" v-if="!showLogo">
        <div class="h-left">
          <i class="icon-ic_header_hamberg font_family">
            <img :src="image.menu" alt="" style="width:18px; height: 18px" @click="getDrawer">
          </i>
        </div>
        <el-breadcrumb-item>
          <div>
            <router-link to="/main/home" style="cursor: pointer">
              我的课堂
            </router-link>
            <span v-for="router in router_list">
              <i class="el-breadcrumb__separator el-icon-arrow-right">
                <img :src="image.rightRow" width="14px" height="14px" style="margin-bottom: -2px">
              </i>
              <router-link :to="router.link" :style="{fontWeight: router.name === router_list[router_list.length - 1].name ? 'bold' : 400}">
                {{ router.name }}
              </router-link>
            </span>
          </div>
        </el-breadcrumb-item>
      </div>

      <div class="h-right">
        <div class="aitools">
          AI工具集
          <span class="wordhot">
            New
          </span>
        </div>
        <div class="papge-check">
          <img :src="image.pageCheck">
          <span>
          论文查重
          </span>
          <span class="wordhot">
            Hot
          </span>
        </div>
        <div class="work-manage">
          <img :src="image.workManage" style="width: 25px; height: 25px">
          <span>
          任务管理
          </span>
        </div>
        <div class="tips">
          <img :src="image.tips" style="width: 22px; height: 22px">
        </div>
        <span class="notice component-notice_count"></span>
        <el-dropdown trigger="click" style="cursor: pointer">
              <span class="el-avatar" style="clip-path: circle(50% at 50% 50%);">
                <img src='../../assets/imags/pdx.jpg' alt="">
              </span>
          <template #dropdown>
            <el-dropdown-menu>
              <el-dropdown-item>开通VIP</el-dropdown-item>
              <el-dropdown-item>机构用户认证</el-dropdown-item>
              <el-dropdown-item @click="getToPage('/login')">退出登录</el-dropdown-item>
              <el-dropdown-item @click="getToPage('/main/setting')">个人信息设置</el-dropdown-item>
            </el-dropdown-menu>
          </template>
        </el-dropdown>
      </div>
    </div>
  </div>
  <el-drawer v-model="showDrawer" :direction="'ltr'">
    <template #header>
      <div style="display: flex">
        <img :src="image.logo" alt=""/>
      </div>
    </template>
    <template #default>
      <div>
        <el-menu
            default-active="2"
            class="el-menu-vertical-demo"
        >
          <el-menu-item index="2">
            <span style="color: black">我的课堂</span>
          </el-menu-item>

          <el-sub-menu index="1">
            <template #title>
              <span>我学的课程</span>
            </template>
            <el-menu-item-group>
              <el-menu-item index="1-1">item one</el-menu-item>
              <el-menu-item index="1-2">item two</el-menu-item>
            </el-menu-item-group>
          </el-sub-menu>
          <div class="el-collapse-item__wrap"></div>

          <el-sub-menu index="2">
            <template #title>
              <span>我协助的课程</span>
            </template>
            <el-menu-item-group>
              <el-menu-item index="1-1">item one</el-menu-item>
              <el-menu-item index="1-2">item two</el-menu-item>
            </el-menu-item-group>
          </el-sub-menu>
          <div class="el-collapse-item__wrap"></div>
        </el-menu>
      </div>
    </template>
  </el-drawer>

</template>

<script setup>
import {image} from "../../assets/index.js";
import {onMounted, ref} from "vue";
import {useRoute} from 'vue-router'
import router from "../../router/index.js";

const props = defineProps({
  router_list: {
    type: Array
  },
  showLogo: {
    type: Boolean
  }
})

const headerIndex = ref('0')

const route = useRoute()

const showDrawer = ref(false)

const getDrawer = () => {
  showDrawer.value = true
}

onMounted(() => {
  console.log(props.router_list)
})

const getToPage = (path) => {
  router.push(path);
}


</script>

<style scoped>
.component-header {
  height: 64px;
  width: 100%;
  margin-bottom: 12px;
  box-sizing: border-box;
  box-shadow: 0 0 10px #ccc;
  display: flex;

  .header-content {
    width: 100%;
    font-size: 14px;
    position: fixed;
    background-color: #fff;
    z-index: 999;
    top: 0;
    left: 0;
    height: 64px;
    padding: 0 24px;
    min-width: 900px;
    display: flex;
    flex-flow: row nowrap;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 1px 0 0 #dfdfdf;

    div {
      .el-breadcrumb__item {
        i {
          margin: 0 6px;
          font-weight: 400;
          display: inline-block;
        }
      }
    }

    .home-header {
      display: flex;
      justify-content: space-between;
      align-items: center;
      width: 235px;

      .el-menu--horizontal.el-menu {
        border: none;
      }

      .el-menu-item {
        color: #4285f4;
        padding: 0;
        margin: 0 20px;
      }
    }

    .el-breadcrumb {
      padding: 0 42px;
      font-size: 14px;
      line-height: 1;
    }


    .h-left {
      cursor: pointer;
    }

    .h-right {
      display: flex;

      .aitools {
        margin-right: 30px;
        font-size: 16px;
        cursor: pointer;
        display: flex;
        align-items: center;
      }

      .papge-check {
        font-size: 16px;
        margin-right: 10px;
        cursor: pointer;
        display: flex;
        align-items: center;
      }

      .work-manage {
        font-size: 16px;
        margin-right: 15px;
        cursor: pointer;
        display: flex;
        align-items: center;
      }

      .wordhot {
        margin-top: -25px;
        margin-left: 0;
        width: 25px;
        height: 14px;
        color: #fd0f0f;
        font-size: 12px;
        font-weight: 700;
      }

      .tips {
        font-size: 16px;
        margin-right: 18px;
        cursor: pointer;
        display: flex;
        align-items: center;
      }

    }
  }

  .el-breadcrumb__item {
    flex: 1;
    padding: 0 42px;
  }
}


</style>
